package example.documentbased.mainModule.services.mocks
{
	import example.documentbased.mainModule.models.doman.Document;
	import example.documentbased.mainModule.models.doman.Editor;
	import example.documentbased.mainModule.models.factories.ItemsFactory;
	
	import flash.utils.Dictionary;
	import flash.utils.setTimeout;
	
	import mx.utils.UIDUtil;

	public class ServiceMockModel
	{
		public var editors:Vector.<Editor>;
		public var documents:Vector.<Document>;
		
		private var _content:Dictionary = new Dictionary();
		private var _itemFactory:ItemsFactory;
		
		public function ServiceMockModel(itemFactory:ItemsFactory)
		{
			_itemFactory = itemFactory;
			init();
		}
		
		public function getContent(document:Document):String
		{
			return _content[document.id] as String;
		}
		
		public function setContent(document:Document, text:String):void
		{
			_content[document.id] = text;
		}
		
		private function init():void
		{
			editors = new Vector.<Editor>();
			editors.push(_itemFactory.createEditor("1", "Test Editor 1", 0xFFFF00));
			editors.push(_itemFactory.createEditor("2", "Test Editor 2", 0xFF00FF));
			
			documents = new Vector.<Document>();
			
			documents.push(_itemFactory.createDocument(UIDUtil.createUID(), UIDUtil.createUID(), editors[0].id, "Editor1.Doc1", "Embedded content."));
			documents.push(_itemFactory.createDocument(UIDUtil.createUID(), UIDUtil.createUID(), editors[0].id, "Editor1.Doc2", "", true));
			//documents.push(_itemFactory.createDocument(UIDUtil.createUID(), UIDUtil.createUID(), editors[1].id, "editor2_doc1", "2-1"));
			//documents.push(_itemFactory.createDocument(UIDUtil.createUID(), UIDUtil.createUID(), editors[1].id, "editor2_doc2", "2-2"));
			
			// set content
			_content[documents[1].id] = "Loaded big content.";
		}
	}
}